﻿#include"XQPush.h"
using namespace XQPush;
XQPush::Error XQPush::toError(const QString& str)
{
	if (str == "NoError")
		return XQPush::Error::NoError;
	else if (str == "Timeout")
		return XQPush::Error::Timeout;
	else if (str == "TimeNotArrived")
		return XQPush::Error::TimeNotArrived;
	else if (str == "AccountNotExist")
		return XQPush::Error::AccountNotExist;
	else if (str == "PasswordError")
		return XQPush::Error::PasswordError;
	return XQPush::Error::UnknownError;
}

QByteArray XQPush::error_toByteArray(Error error)
{
	switch (error)
	{
	case XQPush::NoError:return "NoError";
		break;
	case XQPush::Timeout:return "Timeout";
		break;
	case XQPush::TimeNotArrived:return "TimeNotArrived";
		break;
	case XQPush::AccountNotExist:return "AccountNotExist";
		break;
	case XQPush::PasswordError:return "PasswordError";
		break;
	default:
		return "UnknownError";
		break;
	}
	return QByteArray();
}

XQPush::Result XQPush::toResult(const QString& str)
{
	if (str == "AccountLogin")
		return Result::AccountLogin;
	if (str == "SendVerify")
		return Result::SendVerify;
	return Result::null;
}

QByteArray XQPush::result_toByteArray(Result result)
{
	switch (result)
	{
	case XQPush::AccountLogin:return "AccountLogin";
		break;
	case XQPush::SendVerify:return "SendVerify";
		break;
	default:
		return QByteArray();
		break;
	}
	return QByteArray();
}
